package com.kiven.callback;

interface CallBack2 {
	//接口中所有的方法都默认为public
	void doCRUD();
}

public class HibernateTemplate {
	private void execute(CallBack2 action) {
		getConnection();
		action.doCRUD();
		getClose();
	}
	
	public void doAdd() {
		execute(new CallBack2() {
			@Override
			public void doCRUD() {
				System.out.println("执行add操作");
			}
		});
	}
	
	public void doDelete() {
		execute(new CallBack2() {
			@Override
			public void doCRUD() {
				System.out.println("执行delete操作");
			}
		});
	}
	
	public void getConnection() {
		System.out.println("打开连接");
	}
	
	public void getClose() {
		System.out.println("关闭连接");
	}
	
	public static void main(String[] args) {
		HibernateTemplate ht = new HibernateTemplate();
		ht.doAdd();
	}

}
